#tag Class
Protected Class Score
	#tag Method, Flags = &h0
		Sub AddOwnerColor(pCol as color)
		  select case pCol
		  case PlayerColors.red
		    red = red + 1
		  case PlayerColors.blue
		    blue = blue + 1
		  case PlayerColors.green
		    green = green + 1
		  case PlayerColors.black
		    black = black + 1
		  case PlayerColors.yellow
		    yellow = yellow + 1
		  end select
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub AddScore(s as integer)
		  score = score + s
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h0
		Function GetScore() As integer
		  return score
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function GetOwnerColor() As color
		  dim owner as color
		  dim count as integer = -1
		  
		  
		  if black > count then
		    count = black
		    owner = PlayerColors.black
		  end if
		  
		  if blue > count then
		    count = blue
		    owner = PlayerColors.blue
		  end if
		  
		  if green > count then
		    count = green
		    owner = PlayerColors.green
		  end if
		  
		  if red > count then
		    count = red
		    owner = PlayerColors.Red
		  end if
		  
		  if yellow > count then
		    owner = PlayerColors.Yellow
		  end if
		  
		  return owner
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function IsEven() As boolean
		  dim score() as integer
		  dim highest as integer = -1
		  
		  
		  if black > 0 then
		    score.append black
		  end if
		  
		  if blue > 0 then
		    score.append blue
		  end if
		  
		  if green > 0 then
		    score.append red
		  end if
		  
		  if green > 0 then
		    score.append green
		  end if
		  
		  if yellow > 0 then
		    score.append yellow
		  end if
		  
		  for each s as integer in score
		    if s > highest then
		      highest = s
		    else
		      if s = highest then
		        return true
		      end if
		    end if
		  next
		  
		  return false
		End Function
	#tag EndMethod


	#tag Property, Flags = &h21
		Private score As Integer = 0
	#tag EndProperty

	#tag Property, Flags = &h21
		Private red As Integer = 0
	#tag EndProperty

	#tag Property, Flags = &h21
		Private green As Integer = 0
	#tag EndProperty

	#tag Property, Flags = &h21
		Private yellow As Integer = 0
	#tag EndProperty

	#tag Property, Flags = &h21
		Private blue As Integer = 0
	#tag EndProperty

	#tag Property, Flags = &h21
		Private black As Integer = 0
	#tag EndProperty

	#tag Property, Flags = &h0
		tiles() As board.Tile
	#tag EndProperty


	#tag ViewBehavior
		#tag ViewProperty
			Name="Name"
			Visible=true
			Group="ID"
			InheritedFrom="Object"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Index"
			Visible=true
			Group="ID"
			InitialValue="-2147483648"
			InheritedFrom="Object"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Super"
			Visible=true
			Group="ID"
			InheritedFrom="Object"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Left"
			Visible=true
			Group="Position"
			InitialValue="0"
			InheritedFrom="Object"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Top"
			Visible=true
			Group="Position"
			InitialValue="0"
			InheritedFrom="Object"
		#tag EndViewProperty
	#tag EndViewBehavior
End Class
#tag EndClass
